package com.lzj.myvideo;

import com.lzj.myvideo.interceptor.CrossDomainInterceptor;
import com.lzj.myvideo.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;


@Configuration
public class webMvcConfig extends WebMvcConfigurationSupport {
    /**
     * 资源路径
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler(("/**")).addResourceLocations("file:F:/shortVdeoFile/");
        super.addResourceHandlers(registry);
    }

    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**");
        registry.addInterceptor(new CrossDomainInterceptor()).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}
